/***********************************************************
 
 File name: UIView+frame.h
 Author:    xxuwei
 Description:
 UIView的frame扩展
 
 History:
 2018/02/27: Created
 
 ************************************************************/

#import "UIView+frame.h"

@implementation UIView (frame)
#pragma mark - Getters and Setters Method getter和setter方法
/**
 origin的getter、setter

 */
- (CGPoint)origin {
    return self.frame.origin;
}

- (void)setOrigin:(CGPoint)aPoint {
    CGRect newframe = self.frame;
    newframe.origin = aPoint;
    self.frame = newframe;
}

/**
 size的getter、setter

 */
- (CGSize)size {
    return self.frame.size;
}

- (void)setSize:(CGSize)aSize {
    CGRect newframe = self.frame;
    newframe.size = aSize;
    self.frame = newframe;
}

/**
 height的getter、setter

 */
- (CGFloat)height {
    return self.frame.size.height;
}

- (void)setHeight:(CGFloat)newheight {
    CGRect newframe = self.frame;
    newframe.size.height = newheight;
    self.frame = newframe;
}

/**
 width的getter、setter
 
 */
- (CGFloat)width {
    return self.frame.size.width;
}

- (void)setWidth:(CGFloat)newwidth {
    CGRect newframe = self.frame;
    newframe.size.width = newwidth;
    self.frame = newframe;
}

/**
 top的getter、setter
 
 */
- (CGFloat)top {
    return self.frame.origin.y;
}

- (void)setTop:(CGFloat)newtop {
    CGRect newframe = self.frame;
    newframe.origin.y = newtop;
    self.frame = newframe;
}

/**
 left的getter、setter
 
 */
- (CGFloat)left {
    return self.frame.origin.x;
}

- (void)setLeft:(CGFloat)newleft {
    CGRect newframe = self.frame;
    newframe.origin.x = newleft;
    self.frame = newframe;
}
/**
 bottom的getter、setter
 
 */
- (CGFloat)bottom {
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setBottom:(CGFloat)newbottom {
    CGRect newframe = self.frame;
    newframe.origin.y = newbottom - self.frame.size.height;
    self.frame = newframe;
}
/**
 right的getter、setter
 
 */
- (CGFloat)right {
    return self.frame.origin.x + self.frame.size.width;
}

- (void)setRight:(CGFloat)newright {
    CGFloat delta = newright - (self.frame.origin.x + self.frame.size.width);
    CGRect newframe = self.frame;
    newframe.origin.x += delta ;
    self.frame = newframe;
}

/**
 x的getter、setter
 
 */
- (void)setX:(CGFloat)x {
    CGRect frame = self.frame;
    frame.origin.x = x;
    self.frame = frame;
}

- (CGFloat)x {
      return self.frame.origin.x;
}

/**
 y的getter、setter
 
 */
- (void)setY:(CGFloat)y {
    CGRect frame = self.frame;
     frame.origin.y = y;
    self.frame = frame;
}

- (CGFloat)y {
  return self.frame.origin.y;
}

/**
 centerX的getter、setter
 
 */
- (void)setCenterX:(CGFloat)centerX {
    CGPoint center = self.center;
    center.x = centerX;
    self.center = center;
}

- (CGFloat)centerX {
  return self.center.x;
}

/**
 centerY的getter、setter
 
 */
- (void)setCenterY:(CGFloat)centerY {
        CGPoint center = self.center;
       center.y = centerY;
       self.center = center;
}

- (CGFloat)centerY {
     return self.center.y;
}

@end
